/**
 * Share vids
 */

var share = {

    api_username : 'vdjo',
	
	toggle : function(key) {
		debug.print("share.toggle [key: "+key+"]");
		if (!player[key].video) {
			flash.flash('No video', 'loaded');
			return false;
		};
		if ($("#vid" + key + "-actions > div.share").css("display") == "block")  {
			this.hide(key);
		} else {
			this.show(key);
			this.init(key);
		}
	},
	
	show : function(key) {
		actions.show(key, "share");
	},
	
	hide : function(key) {
		actions.hide(key);
	},
	
	init : function(key) {
		debug.print("share.init [key: "+key+"]");
        var url = "http://api.addthis.com/oexchange/0.8/forward/";
        //var share = "http://beta.vdjo.com/#" + player[key].video.id;
        var share = "http://" + location.hostname + "/#" + player[key].video.id;
        var title = player[key].video.artist + " - " + player[key].video.title + " (watch video on www.vdjo.com, the Music Video Mixer)";
		$("#vid" + key + "-actions div.addthis a").each(function() {
            var addthis = url + $(this).attr("class") + "/offer?";
            addthis = addthis + "url=" + escape(share);
            addthis = addthis + "&title=" + escape(title);
            addthis = addthis + "&username=vdjo";
            $(this).attr("href", addthis);
            $(this).attr("target", "_blank");
        });
	}		
}